﻿using AspDotNet.Core7.First.Services;

namespace AspDotNet.Core7.First.Middlewares
{
    public partial class ContentMiddleware : BaseMiddleware
    {
        TotalUsers Users { get; set; }
        public ContentMiddleware(RequestDelegate nextMiddleware, TotalUsers users)
            : base(nextMiddleware)
        {
            this.Users = users;
        }

        public override async Task Invoke(HttpContext httpContext)
        {
            if (httpContext.Request.Path.ToString() == "/middleware")
            {
                await httpContext.Response.WriteAsync("This is from the content middleware, Total Users: " + Users.TUsers());
            }
            else
            {
                await NextMiddleware.Invoke(httpContext);
            }
        }
    }
}
